<!DOCTYPE html>
<html >
<head>

    <!--[if lt IE 9]>
        <style>body {display: none; background: none !important} </style>
        <meta http-equiv="Refresh" Content="0; url=//outdatedbrowser.com/" />
    <![endif]-->

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="format-detection" content="telephone=no" />
<meta name="author" content="Mark" />



<meta name="description" content="Qt 中pro文件涉及到对项目的一些配置">
<meta property="og:type" content="article">
<meta property="og:title" content="Qt pro文件写法">
<meta property="og:url" content="http://markma.tk/posts/QtStudy/Qt中pro文件写法/index.html">
<meta property="og:site_name" content="Mark's Blog">
<meta property="og:description" content="Qt 中pro文件涉及到对项目的一些配置">
<meta property="og:updated_time" content="2017-07-06T03:20:52.465Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Qt pro文件写法">
<meta name="twitter:description" content="Qt 中pro文件涉及到对项目的一些配置">

<link rel="apple-touch-icon" href= "/apple-touch-icon.png">




    <link rel="shortcut icon" href="/favicon.png">



    <link href="//cdn.bootcss.com/animate.css/3.5.1/animate.min.css" rel="stylesheet">



    <link href="//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.css" rel="stylesheet">



    <script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script>
    <link href="//cdn.bootcss.com/pace/1.0.2/themes/blue/pace-theme-minimal.css" rel="stylesheet">


<link rel="stylesheet" href="/css/style.css">



<link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">


<title>Qt pro文件写法 | Mark&#39;s Blog</title>

<script src="//cdn.bootcss.com/jquery/2.2.4/jquery.min.js"></script>
<script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>

<script>
    var yiliaConfig = {
        fancybox: true,
        animate: true,
        isHome: false,
        isPost: true,
        isArchive: false,
        isTag: false,
        isCategory: false,
        fancybox_js: "//cdn.bootcss.com/fancybox/2.1.5/jquery.fancybox.min.js",
        scrollreveal: "//cdn.bootcss.com/scrollReveal.js/3.1.4/scrollreveal.min.js",
        search: true
    }
</script>


    <script>
        yiliaConfig.jquery_ui = [true, "//cdn.bootcss.com/jqueryui/1.10.4/jquery-ui.min.js", "//cdn.bootcss.com/jqueryui/1.10.4/css/jquery-ui.min.css"];
    </script>



    <script> yiliaConfig.rootUrl = "\/";</script>





    <script>
        var _hmt = _hmt || [];
        (function() {
            var hm = document.createElement("script");
            hm.src = "//hm.baidu.com/hm.js?fad5c01287c961d95e4fe533d91c8aab";
            var s = document.getElementsByTagName("script")[0]; 
            s.parentNode.insertBefore(hm, s);
        })();
    </script>


</head>
<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
    <header id="header" class="inner">
        <a href="/" class="profilepic">
            <img src="/img/avatar.png" class="animated zoomIn">
        </a>
        <hgroup>
          <h1 class="header-author"><a href="/">Mark</a></h1>
        </hgroup>

        
        <p class="header-subtitle">To do to make progress</p>
        

        
            <form id="search-form">
            <input type="text" id="local-search-input" name="q" placeholder="search..." class="search form-control" autocomplete="off" autocorrect="off" searchonload="false" />
            <i class="fa fa-times" onclick="resetSearch()"></i>
            </form>
            <div id="local-search-result"></div>
            <p class='no-result'>No results found <i class='fa fa-spinner fa-pulse'></i></p>
        


        
            <div id="switch-btn" class="switch-btn">
                <div class="icon">
                    <div class="icon-ctn">
                        <div class="icon-wrap icon-house" data-idx="0">
                            <div class="birdhouse"></div>
                            <div class="birdhouse_holes"></div>
                        </div>
                        <div class="icon-wrap icon-ribbon hide" data-idx="1">
                            <div class="ribbon"></div>
                        </div>
                        
                        <div class="icon-wrap icon-link hide" data-idx="2">
                            <div class="loopback_l"></div>
                            <div class="loopback_r"></div>
                        </div>
                        
                        
                        <div class="icon-wrap icon-me hide" data-idx="3">
                            <div class="user"></div>
                            <div class="shoulder"></div>
                        </div>
                        
                    </div>
                    
                </div>
                <div class="tips-box hide">
                    <div class="tips-arrow"></div>
                    <ul class="tips-inner">
                        <li>Menu</li>
                        <li>Tags</li>
                        
                        <li>Friends</li>
                        
                        
                        <li>About Me</li>
                        
                    </ul>
                </div>
            </div>
        

        <div id="switch-area" class="switch-area">
            <div class="switch-wrap">
                <section class="switch-part switch-part1">
                    <nav class="header-menu">
                        <ul>
                        
                            <li><a href="/">主页</a></li>
                        
                            <li><a href="/tags/">分类</a></li>
                        
                            <li><a href="/archives/">归档</a></li>
                        
                            <li><a href="/gallery/">相册</a></li>
                        
                            <li><a href="/about/">关于我</a></li>
                        
                        </ul>
                    </nav>
                    <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" href="mailto:ma-mark@outlook.com" title="Email"></a>
                            
                                <a class="fa 新浪微博" href="http://weibo.com/mark900" title="新浪微博"></a>
                            
                                <a class="fa GitHub" href="https://github.com/markma" title="GitHub"></a>
                            
                                <a class="fa 知乎" href="https://www.zhihu.com/people/mark900" title="知乎"></a>
                            
                                <a class="fa Coding" href="https://coding.net/u/maxiaohang" title="Coding"></a>
                            
                                <a class="fa 网易云音乐" href="http://music.163.com/#/user/home?id=115229883" title="网易云音乐"></a>
                            
                                <a class="fa QQ" href="http://wpa.qq.com/msgrd?v=3&uin=954373276&site=qq&menu=yes" title="QQ"></a>
                            
                        </ul>
                    </nav>
                </section>
                
                
                <section class="switch-part switch-part2">
                    <div class="widget tagcloud" id="js-tagcloud">
                        <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/Cpp/">Cpp</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Hexo/">Hexo</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Journal/">Journal</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Matlab/">Matlab</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/OpenLibrary/">OpenLibrary</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Python/">Python</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Qt/">Qt</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Robot/">Robot</a></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Wiki/">Wiki</a></li></ul>
                    </div>
                </section>
                
                
                
                <section class="switch-part switch-part3">
                    <div id="js-friends">
                    
                      <a class="main-nav-link switch-friends-link" href="http://moxfive.xyz/">MOxFIVE</a>
                    
                    </div>
                </section>
                

                
                
                <section class="switch-part switch-part4">
                
                    <div id="js-aboutme">因为爱好，做着自己本不该做的事。为爱而活，不受羁绊！</div>
                </section>
                
            </div>
        </div>
    </header>                
</div>
    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
      <div class="overlay">
          <div class="slider-trigger"></div>
          <h1 class="header-author js-mobile-header hide"><a href="/" title="回到主页">Mark</a></h1>
      </div>
    <div class="intrude-less">
        <header id="header" class="inner">
            <a href="/" class="profilepic">
                <img src="/img/avatar.png" class="animated zoomIn">
            </a>
            <hgroup>
              <h1 class="header-author"><a href="/" title="回到主页">Mark</a></h1>
            </hgroup>
            
            <p class="header-subtitle">To do to make progress</p>
            
            <nav class="header-menu">
                <ul>
                
                    <li><a href="/">主页</a></li>
                
                    <li><a href="/tags/">分类</a></li>
                
                    <li><a href="/archives/">归档</a></li>
                
                    <li><a href="/gallery/">相册</a></li>
                
                    <li><a href="/about/">关于我</a></li>
                
                <div class="clearfix"></div>
                </ul>
            </nav>
            <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fa Email" target="_blank" href="mailto:ma-mark@outlook.com" title="Email"></a>
                            
                                <a class="fa 新浪微博" target="_blank" href="http://weibo.com/mark900" title="新浪微博"></a>
                            
                                <a class="fa GitHub" target="_blank" href="https://github.com/markma" title="GitHub"></a>
                            
                                <a class="fa 知乎" target="_blank" href="https://www.zhihu.com/people/mark900" title="知乎"></a>
                            
                                <a class="fa Coding" target="_blank" href="https://coding.net/u/maxiaohang" title="Coding"></a>
                            
                                <a class="fa 网易云音乐" target="_blank" href="http://music.163.com/#/user/home?id=115229883" title="网易云音乐"></a>
                            
                                <a class="fa QQ" target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=954373276&site=qq&menu=yes" title="QQ"></a>
                            
                        </ul>
            </nav>
        </header>                
    </div>
    <link class="menu-list" tags="Tags" friends="Friends" about="About Me"/>
</nav>
      <div class="body-wrap"><article id="post-posts/QtStudy/Qt中pro文件写法" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/posts/QtStudy/Qt中pro文件写法/" class="article-date">
      <time datetime="2017-04-19T11:29:00.000Z" itemprop="datePublished">2017-04-19</time>
</a>


    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      Qt pro文件写法
    </h1>
  

      </header>
      
      <div class="article-info article-info-post">
        
    <div class="article-category tagcloud">
    <a class="article-category-link" href="/categories/QtStudy/">QtStudy</a>
    </div>


        
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Cpp/">Cpp</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Qt/">Qt</a></li></ul>
    </div>

        <div class="clearfix"></div>
      </div>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <blockquote>
<p>Qt 中pro文件涉及到对项目的一些配置<br><a id="more"></a></p>
</blockquote>
<h1 id="语法简介"><a href="#语法简介" class="headerlink" title="语法简介"></a>语法简介</h1><h2 id="操作符"><a href="#操作符" class="headerlink" title="操作符"></a>操作符</h2><p>到目前为止，你已经看到在项目文件中使用的=操作符和+=操作符。这里能够提供更多的可供使用的操作符，但是其中的一些需要谨慎地使用，因为它们也许会比你期待的改变的更多。</p>
<h3 id="“-”操作符"><a href="#“-”操作符" class="headerlink" title="“=”操作符"></a>“=”操作符</h3><p>这个操作符简单分配一个值给一个变量。使用方法如下：</p>
<pre><code>TARGET = myapp
</code></pre><p>这将会设置TARGET变量为myapp。这将会删除原来对TARGET的任何设置。</p>
<h3 id="“-”操作符-1"><a href="#“-”操作符-1" class="headerlink" title="“+=”操作符"></a>“+=”操作符</h3><p>这个操作符将会向一个变量的值的列表中添加一个值。使用方法如下：</p>
<pre><code>DEFINES += QT_DLL
</code></pre><p>这将会把QT_DLL添加到被放到makefile中的预处理定义的列表中。</p>
<h3 id="“-”操作符-2"><a href="#“-”操作符-2" class="headerlink" title="“-=”操作符"></a>“-=”操作符</h3><p>这个操作符将会从一个变量的值的列表中移去一个值。使用方法如下：</p>
<pre><code>DEFINES -= QT_DLL
</code></pre><p>这将会从被放到makefile中的预处理定义的列表中移去QT_DLL。</p>
<h3 id="“-”操作符-3"><a href="#“-”操作符-3" class="headerlink" title="“*=”操作符"></a>“*=”操作符</h3><p>这个操作符仅仅在一个值不存在于一个变量的值的列表中的时候，把它添加进去。使用方法如下：</p>
<pre><code>DEFINES *= QT_DLL
</code></pre><p>只用在QT_DLL没有被定义在预处理定义的列表中时，它才会被添加进去。</p>
<h3 id="“-”操作符-4"><a href="#“-”操作符-4" class="headerlink" title="“~=”操作符"></a>“~=”操作符</h3><p>这个操作符将会替换任何与指定的值的正则表达式匹配的任何值。使用方法如下：</p>
<pre><code>DEFINES ~= s/QT_[DT].+/QT
</code></pre><p>这将会用QT来替代任何以QT_D或QT_T开头的变量中的QT_D或QT_T。</p>
<h2 id="作用域"><a href="#作用域" class="headerlink" title="作用域"></a>作用域</h2><p>作用域和“if”语句很相似，如果某个条件为真，作用域中的设置就会被处理。作用域使用方法如下：</p>
<pre><code>win32 {
    DEFINES += QT_DLL
}
</code></pre><p>上面的代码的作用是，如果在Windows平台上使用qmake，QT_DLL定义就会被添加到makefile中。如果在Windows平台以外的平台上使用qmake，这个定义就会被忽略。你也可以使用qmake执行一个单行的条件/任务，就像这样：</p>
<pre><code>win32:DEFINES += QT_DLL
</code></pre><p>比如，假设我们想在除了Windows平台意外的所有平台处理些什么。我们想这样使用作用域来达到这种否定效果：</p>
<pre><code>!win32 {
    DEFINES += QT_DLL
}
</code></pre><p>CONFIG行中的任何条目也都是一个作用域。比如，你这样写：</p>
<pre><code>CONFIG += warn_on
</code></pre><p>你将会得到一个称作“warn_on”的作用域。这样将会使在不丢失特定条件下可能所需的所有自定义设置的条件下，很容易地修改项目中的配置。因为你可能把你自己的值放到CONFIG行中，这将会为你的makefile而提供给你一个非常强大的配置工具。比如：</p>
<pre><code>CONFIG += qt warn_on debug
debug {
    TARGET = myappdebug
}
release {
    TARGET = myapp
}
</code></pre><p>在上面的代码中，两个作用域被创建，它们依赖于CONFIG行中设置的是什么。在这个例子中，debug在CONFIG行中，所以TARGET变量被设置为myappdebug。如果release在CONFIG行中，那么TARGET变量将会被设置为myapp。</p>
<p>当然也可以在处理一些设置之前检查两个事物。例如，如果你想检查平台是否是Windows并且线程设置是否被设定，你可以这样写：</p>
<pre><code>win32 {
    thread {
        DEFINES += QT_THREAD_SUPPORT
    }
}
</code></pre><p>为了避免写出许多嵌套作用域，你可以这样使用冒号来嵌套作用域：</p>
<pre><code>win32:thread {
    DEFINES += QT_THREAD_SUPPORT
}
</code></pre><p>一旦一个测试被执行，你也许也要做else/elseif操作。这种情况下，你可以很容易地写出复杂的测试。这需要使用特殊的“else”作用域，它可以和其它作用域进行组合（也可以向上面一样使用冒号），比如：</p>
<pre><code>win32:thread {
    DEFINES += QT_THREAD_SUPPORT
} else:debug {
    DEFINES += QT_NOTHREAD_DEBUG
} else {
    warning(&quot;Unknown configuration&quot;)
}
</code></pre><h2 id="变量"><a href="#变量" class="headerlink" title="变量"></a>变量</h2><p>到目前为止我们遇到的变量都是系统变量，比如DEFINES、SOURCES和HEADERS。你也可以为你自己创建自己的变量，这样你就可以在作用域中使用它们了。创建自己的变量很容易，只要命名它并且分配一些东西给它。比如：</p>
<pre><code>MY_VARIABLE = value
</code></pre><p>现在你对你自己的变量做什么是没有限制的，同样地，qmake将会忽略它们，除非需要在一个作用域中考虑它们。</p>
<p>你也可以通过在其它任何一个变量的变量名前加$$来把这个变量的值分配给当前的变量。例如：</p>
<pre><code>MY_DEFINES = $$DEFINES
</code></pre><p>现在MY_DEFINES变量包含了项目文件在这点时DEFINES变量的值。这也和下面的语句一样：</p>
<pre><code>MY_DEFINES = $${DEFINES}
</code></pre><p>第二种方法允许你把一个变量和其它变量连接起来，而不用使用空格。qmake将允许一个变量包含任何东西（包括<code>$(VALUE)</code>，可以直接在makefile中直接放置，并且允许它适当地扩张，通常是一个环境变量）。无论如何，如果你需要立即设置一个环境变量，然后你就可以使用<code>$$()</code>方法。比如：</p>
<pre><code>MY_DEFINES = $$(ENV_DEFINES)
</code></pre><p>这将会设置MY_DEFINES为环境变量ENV_DEFINES传递给.pro文件地值。另外你可以在替换的变量里调用内置函数。这些函数（不会和下一节中列举的测试函数混淆）列出如下：</p>
<h2 id="内置函数"><a href="#内置函数" class="headerlink" title="内置函数"></a>内置函数</h2><p>join( variablename, glue, before, after )</p>
<p>这将会在variablename的各个值中间加入glue。如果这个变量的值为非空，那么就会在值的前面加一个前缀before和一个后缀after。只有variablename是必须的字段，其它默认情况下为空串。如果你需要在glue、before或者after中使用空格的话，你必须提供它们。</p>
<p>member( variablename, position )</p>
<p>这将会放置variablename的列表中的position位置的值。如果variablename不够长，这将会返回一个空串。variablename是唯一必须的字段，如果没有指定位置，则默认为列表中的第一个值。</p>
<p>find( variablename, substr )</p>
<p>这将会放置variablename中所有匹配substr的值。substr也可以是正则表达式，而因此将被匹配。</p>
<pre><code>MY_VAR = one two three four
MY_VAR2 = $$join(MY_VAR, &quot; -L&quot;, -L) -Lfive
MY_VAR3 = $$member(MY_VAR, 2) $$find(MY_VAR, t.*)
</code></pre><p>MY_VAR2将会包含“-Lone -Ltwo -Lthree -Lfour -Lfive”，并且MYVAR3将会包含“three two three”。</p>
<p>system( program_and_args )</p>
<p>这将会返回程序执行在标准输出/标准错误输出的内容，并且正像平时所期待地分析它。比如你可以使用这个来询问有关平台的信息。</p>
<pre><code>UNAME = $$system(uname -s)
contains( UNAME, [lL]inux ):message( This looks like Linux ($$UNAME) to me )
</code></pre><h2 id="测试函数"><a href="#测试函数" class="headerlink" title="测试函数"></a>测试函数</h2><p>qmake提供了可以简单执行，但强大测试的内置函数。这些测试也可以用在作用域中（就像上面一样），在一些情况下，忽略它的测试值，它自己使用测试函数是很有用的。</p>
<p>contains( variablename, value )</p>
<p>如果value存在于一个被叫做variablename的变量的值的列表中，那么这个作用域中的设置将会被处理。例如：</p>
<pre><code>contains( CONFIG, thread ) {
    DEFINES += QT_THREAD_SUPPORT
}
</code></pre><p>如果thread存在于CONFIG变量的值的列表中时，那么QT_THREAD_SUPPORT将会被加入到DEFINES变量的值的列表中。</p>
<p>count( variablename, number )</p>
<p>如果number与一个被叫做variablename的变量的值的数量一致，那么这个作用域中的设置将会被处理。例如：</p>
<pre><code>count( DEFINES, 5 ) {
    CONFIG += debug
}
</code></pre><p>error( string )</p>
<p>这个函数输出所给定的字符串，然后会使qmake退出。例如：</p>
<pre><code>error( &quot;An error has occured&quot; )
</code></pre><p>文本“An error has occured”将会被显示在控制台上并且qmake将会退出。</p>
<p>exists( filename )</p>
<p>如果指定文件存在，那么这个作用域中的设置将会被处理。例如：</p>
<pre><code>exists( /local/qt/qmake/main.cpp ) {
    SOURCES += main.cpp
}
</code></pre><p>如果/local/qt/qmake/main.cpp存在，那么main.cpp将会被添加到源文件列表中。</p>
<p>注意可以不用考虑平台使用“/”作为目录的分隔符。</p>
<p>include( filename )</p>
<p>项目文件在这一点时包含这个文件名的内容，所以指定文件中的任何设置都将会被处理。例如：</p>
<pre><code>include( myotherapp.pro )
</code></pre><p>myotherapp.pro项目文件中的任何设置现在都会被处理。</p>
<p>isEmpty( variablename )</p>
<p>这和使用count( variablename, 0 )是一样的。如果叫做variablename的变量没有任何元素，那么这个作用域中的设置将会被处理。例如：</p>
<pre><code>isEmpty( CONFIG ) {
    CONFIG += qt warn_on debug
}
</code></pre><p>message( string )</p>
<p>这个函数只是简单地在控制台上输出消息。</p>
<pre><code>message( &quot;This is a message&quot; )
</code></pre><p>文本“This is a message”被输出到控制台上并且对于项目文件的处理将会继续进行。</p>
<p>system( command )</p>
<p>特定指令被执行并且如果它返回一个1的退出值，那么这个作用域中的设置将会被处理。例如：</p>
<pre><code>system( ls /bin ) {
    SOURCES += bin/main.cpp
    HEADERS += bin/main.h
}
</code></pre><p>所以如果命令ls /bin返回1，那么bin/main.cpp将被添加到源文件列表中并且bin/main.h将被添加到头文件列表中。</p>
<p>infile( filename, var, val )</p>
<p>如果filename文件（当它被qmake自己解析时）包含一个值为val的变量var，那么这个函数将会返回成功。你也可以不传递第三个参数（val），这时函数将只测试文件中是否分配有这样一个变量var。</p>
<h1 id="应用举例"><a href="#应用举例" class="headerlink" title="应用举例"></a>应用举例</h1><h2 id="条件编译，判断编译环境，调用合适的链接库"><a href="#条件编译，判断编译环境，调用合适的链接库" class="headerlink" title="条件编译，判断编译环境，调用合适的链接库"></a>条件编译，判断编译环境，调用合适的链接库</h2><h3 id="1-判断编译器架构"><a href="#1-判断编译器架构" class="headerlink" title="1. 判断编译器架构"></a>1. 判断编译器架构</h3><pre><code>win32:contains(QMAKE_HOST.arch, x86_64) {
LIBS += -L$$PWD/x64/ -laticonvert
} else {
LIBS += -L$$PWD/x86/ -laticonvert
}
</code></pre><p>或者<br>    win32:contains(QT_ARCH, i386) {<br>    LIBS += -L$$PWD/x64/ -laticonvert<br>    } else {<br>    LIBS += -L$$PWD/x86/ -laticonvert<br>    }<br>或者<br>    win32:contains(DEFINES, WIN64) {<br>    LIBS += -L$$PWD/x64/ -laticonvert<br>    } else {<br>    contains(DEFINES, WIN32){<br>    LIBS += -L$$PWD/x86/ -laticonvert<br>    }else {<br>    message(“win mingw”)<br>    }<br>    }</p>
<h3 id="2-判断debug-或-release"><a href="#2-判断debug-或-release" class="headerlink" title="2. 判断debug 或 release"></a>2. 判断debug 或 release</h3><pre><code>CONFIG+=debug_and_release
CONFIG(debug, debug|release){
TARGET = ui_debug
} else {
TARGET = ui_release
}

CONFIG(debug, debug|release) {
LIBS += -L../lib1 -lhellod
} else {
LIBS += -L../lib2 -lhello
}

CONFIG(debug, debug|release)：LIBS += -L../lib1 -lhellod
CONFIG(release, debug|release)：LIBS += -L../lib2 -lhello
</code></pre><h3 id="使用总结：适用于windows环境中msvc32-msvc64-minGW-三种编译环境"><a href="#使用总结：适用于windows环境中msvc32-msvc64-minGW-三种编译环境" class="headerlink" title="使用总结：适用于windows环境中msvc32 msvc64 minGW 三种编译环境"></a>使用总结：适用于windows环境中msvc32 msvc64 minGW 三种编译环境</h3><pre><code>win32:contains(DEFINES, WIN64) {
    CONFIG(debug,debug | release):{
        message(&quot;WIN64 debug&quot;)
    } else {
        message(&quot;WIN64 release&quot;)
    }
}else{
    contains(DEFINES, WIN32){
        CONFIG(debug,debug | release):{
            message(&quot;WIN32 debug&quot;)
        } else {
            message(&quot;WIN32 release&quot;)
        }
    }else{
        CONFIG(debug,debug | release):{
            message(&quot;mingGW debug&quot;)
        } else {
            message(&quot;mingGW release&quot;)
        }
}
</code></pre><h2 id="通过include-对多个库进行便捷引用和管理"><a href="#通过include-对多个库进行便捷引用和管理" class="headerlink" title="通过include()对多个库进行便捷引用和管理"></a>通过include()对多个库进行便捷引用和管理</h2><pre><code>include(Libraries/CML/LinkCML.pri)
include(Libraries/BOT/LinkRobot.pri)
include(Libraries/MPC08/LinkMpc08.pri)
include(Libraries/fuzzy/LinkFL.pri)
include(Libraries/FT/LinkFT.pri)
include(Libraries/polaris/LinkNDI.pri)
include(Libraries/MillToolCtrl/LinkMillTool.pri)
</code></pre><p>LinkNDI.pri<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line">QT += serialport</div><div class="line"></div><div class="line">INCLUDEPATH += $$PWD</div><div class="line"></div><div class="line">SOURCES += \</div><div class="line">    $$PWD/comm32.cpp \</div><div class="line">    $$PWD/conversion.cpp \</div><div class="line">    $$PWD/baseFunc.cpp \</div><div class="line">    $$PWD/systemCRC.cpp \</div><div class="line">    $$PWD/ndiwidget.cpp</div><div class="line"></div><div class="line">HEADERS +=$$PWD/ndiwidget.h</div><div class="line"></div><div class="line">FORMS+= $$PWD/ndiwidget.ui</div></pre></td></tr></table></figure></p>
<p>…</p>

      
    </div>
    
  </div>
  
    
    <div class="copyright">
        <p><span>Title:</span><a href="/posts/QtStudy/Qt中pro文件写法/">Qt pro文件写法</a></p>
        <p><span>Author:</span><a href="/" title="Back to Homepage">Mark</a></p>
        <p><span>Created:</span>2017-04-19, 19:29:00</p>
        <p><span>Updated:</span>2017-07-06, 11:20:52</p>
        <p>
            <span>Full URL:</span><a class="post-url" href="/posts/QtStudy/Qt中pro文件写法/" title="Qt pro文件写法">http://markma.tk/posts/QtStudy/Qt中pro文件写法/</a>
            <span class="copy-path" data-clipboard-text="From http://markma.tk/posts/QtStudy/Qt中pro文件写法/　　By Mark" title="Copy Article&#39;s Link &amp; Author"><i class="fa fa-clipboard"></i></span>
            <script> var clipboard = new Clipboard('.copy-path'); </script>
        </p>
        <p>
            <span>License:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" title="CC BY-NC-SA 4.0 International" target = "_blank">"CC BY-NC-SA 4.0"</a> Keep Link &amp; Author if Distribute.
        </p>
    </div>



    <nav id="article-nav">
        
            <div id="article-nav-newer" class="article-nav-title">
                <a href="/posts/QtStudy/Cpp中回调函数与静态成员/">
                    Cpp中回调函数与静态成员
                </a>
            </div>
        
        
            <div id="article-nav-older" class="article-nav-title">
                <a href="/posts/OpenSource/Qt串口开发QextserialPort/">
                    Qt串口开发QextserialPort
                </a>
            </div>
        
    </nav>

  
</article>

    <div id="toc" class="toc-article">
        <strong class="toc-title">Contents</strong>
        
            <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#语法简介"><span class="toc-number">1.</span> <span class="toc-text">语法简介</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#操作符"><span class="toc-number">1.1.</span> <span class="toc-text">操作符</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#“-”操作符"><span class="toc-number">1.1.1.</span> <span class="toc-text">“=”操作符</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#“-”操作符-1"><span class="toc-number">1.1.2.</span> <span class="toc-text">“+=”操作符</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#“-”操作符-2"><span class="toc-number">1.1.3.</span> <span class="toc-text">“-=”操作符</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#“-”操作符-3"><span class="toc-number">1.1.4.</span> <span class="toc-text">“*=”操作符</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#“-”操作符-4"><span class="toc-number">1.1.5.</span> <span class="toc-text">“~=”操作符</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#作用域"><span class="toc-number">1.2.</span> <span class="toc-text">作用域</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#变量"><span class="toc-number">1.3.</span> <span class="toc-text">变量</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#内置函数"><span class="toc-number">1.4.</span> <span class="toc-text">内置函数</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#测试函数"><span class="toc-number">1.5.</span> <span class="toc-text">测试函数</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#应用举例"><span class="toc-number">2.</span> <span class="toc-text">应用举例</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#条件编译，判断编译环境，调用合适的链接库"><span class="toc-number">2.1.</span> <span class="toc-text">条件编译，判断编译环境，调用合适的链接库</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-判断编译器架构"><span class="toc-number">2.1.1.</span> <span class="toc-text">1. 判断编译器架构</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-判断debug-或-release"><span class="toc-number">2.1.2.</span> <span class="toc-text">2. 判断debug 或 release</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#使用总结：适用于windows环境中msvc32-msvc64-minGW-三种编译环境"><span class="toc-number">2.1.3.</span> <span class="toc-text">使用总结：适用于windows环境中msvc32 msvc64 minGW 三种编译环境</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#通过include-对多个库进行便捷引用和管理"><span class="toc-number">2.2.</span> <span class="toc-text">通过include()对多个库进行便捷引用和管理</span></a></li></ol></li></ol>
        
    </div>
    <style>
        .left-col .switch-btn,
        .left-col .switch-area {
            display: none;
        }
        .toc-level-3 i,
        .toc-level-3 ol {
            display: none !important;
        }
    </style>

    <input type="button" id="tocButton" value="Hide"  title="Show or Hide Table of Contents">

    <script>
        yiliaConfig.toc = ["Hide", "Show", !!"false"];
    </script>



    
<div class="share">
    
        <div class="bdsharebuttonbox">
            <a href="#" class="fa fa-twitter bds_twi" data-cmd="twi" title="分享到推特"></a>
            <a href="#" class="fa fa-weibo bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
            <a href="#" class="fa fa-qq bds_sqq" data-cmd="sqq" title="分享给 QQ 好友"></a>
            <a href="#" class="fa fa-files-o bds_copy" data-cmd="copy" title="复制网址"></a>
            <a href="#" class="fa fa fa-envelope-o bds_mail" data-cmd="mail" title="通过邮件分享"></a>
            <a href="#" class="fa fa-weixin bds_weixin" data-cmd="weixin" title="生成文章二维码"></a>
            <a href="#" class="fa fa-share-alt bds_more" data-cmd="more"></i></a>
        </div>
        <script>
            window._bd_share_config={
                "common":{"bdSnsKey":{},"bdText":"Qt pro文件写法　| Mark's Blog　","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
        </script>
    

    
</div>







    
      <div class="duoshuo" id="comments">
    <div id="comment-box" ></div>
    <div class="ds-thread" id="ds-thread" data-thread-key="posts/QtStudy/Qt中pro文件写法/" data-title="Qt pro文件写法" data-url="http://markma.tk/posts/QtStudy/Qt中pro文件写法/"></div>
    <script>
        var duoshuoQuery = {short_name:"markma"};
        var loadComment = function(){
            var d = document, s = d.createElement('script');
            s.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
            s.async = true; s.charset = 'UTF-8';
            (d.head || d.body).appendChild(s);
        }

        
    </script>
    
    <script> loadComment(); </script>

</div>
    




    <div class="scroll" id="post-nav-button">
        
            <a href="/posts/QtStudy/Cpp中回调函数与静态成员/" title="Pre: Cpp中回调函数与静态成员">
                <i class="fa fa-angle-left"></i>
            </a>
        

        <a title="Mini Archives"><i class="fa fa-bars"></i><i class="fa fa-times"></i></a>

        
            <a href="/posts/OpenSource/Qt串口开发QextserialPort/" title="Next: Qt串口开发QextserialPort">
                <i class="fa fa-angle-right"></i>
            </a>
        
    </div>

    <ul class="post-list"><li class="post-list-item"><a class="post-list-link" href="/posts/Matlab/matlab cpp混编/">matlab cpp混编</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/QtStudy/Cpp中回调函数与静态成员/">Cpp中回调函数与静态成员</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/QtStudy/Qt中pro文件写法/">Qt pro文件写法</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/OpenSource/Qt串口开发QextserialPort/">Qt串口开发QextserialPort</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/QtStudy/Qt常见错误汇总/">Qt 常见错误汇总</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/OpenSource/Qt绘图库QCustomplot/">Qt绘图库 QCustomPlot</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/OpenSource/cpp机器人库robot-library/">cpp机器人库robot-library</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/OpenSource/开源库大全/">开源库大全</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/Python/Python-入门学习（二）/">Python-入门学习（二）</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/Python/Python-入门学习（一）/">Python-入门学习（一）</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/QtStudy/Qt中界面类名的修改/">Qt ui界面调用</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/Hexo/HEXO-Github-快速搭建属于自己的博客/">HEXO+Github Create your Blog</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/Journal/hello-world/">Hello World</a></li></ul>




    <script>
        
    </script>
</div>
      <footer id="footer">
    <div class="outer">
        <div id="footer-info">
            <div class="footer-left">
                <i class="fa fa-copyright"></i> 
                2016-2017 Mark
            </div>
            <div class="footer-right">
                <a href="http://hexo.io/" target="_blank" title="A fast, simple &amp; powerful blog framework">Hexo</a>  Theme <a href="https://github.com/MOxFIVE/hexo-theme-yelee" target="_blank" title="Another simple and elegant theme for Hexo  v3.5">Yelee</a> by MOxFIVE <i class="fa fa-heart animated infinite pulse"></i>
            </div>
        </div>
        
            <div class="visit">
                
                    <span id="busuanzi_container_site_pv" style='display:none'>
                        <span id="site-visit" title="Site Visitors"><i class="fa fa-user" aria-hidden="true"></i><span id="busuanzi_value_site_uv"></span>
                        </span>
                    </span>
                
                
                    <span>| </span>
                
                
                    <span id="busuanzi_container_page_pv" style='display:none'>
                        <span id="page-visit"  title="Page Hits"><i class="fa fa-eye animated infinite pulse" aria-hidden="true"></i><span id="busuanzi_value_page_pv"></span>
                        </span>
                    </span>
                
            </div>
        
    </div>
</footer>
    </div>
    
<script data-main="/js/main.js" src="//cdn.bootcss.com/require.js/2.2.0/require.min.js"></script>

    <script>
        $(document).ready(function() {
            var iPad = window.navigator.userAgent.indexOf('iPad');
            if (iPad > -1 || $(".left-col").css("display") === "none") {
                var bgColorList = ["#9db3f4", "#414141", "#e5a859", "#f5dfc6", "#c084a0", "#847e72", "#cd8390", "#996731"];
                var bgColor = Math.ceil(Math.random() * (bgColorList.length - 1));
                $("body").css({"background-color": bgColorList[bgColor], "background-size": "cover"});
            }
            else {
                var backgroundnum = 27;
                var backgroundimg = "url(/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
                $("body").css({"background": backgroundimg, "background-attachment": "fixed", "background-size": "cover"});
            }
        })
    </script>





    <script type="text/x-mathjax-config">
MathJax.Hub.Config({
    tex2jax: {
        inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
        processEscapes: true,
        skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
    }
});

MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
        all[i].SourceElement().parentNode.className += ' has-jax';                 
    }       
});
</script>

<script src="//cdn.bootcss.com/mathjax/2.6.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>


<div class="scroll" id="scroll">
    <a href="#" title="Back to Top"><i class="fa fa-arrow-up"></i></a>
    <a href="#comments" onclick="load$hide();" title="Comments"><i class="fa fa-comments-o"></i></a>
    <a href="#footer" title="Go to Bottom"><i class="fa fa-arrow-down"></i></a>
</div>
<script>
    // Open in New Window
    
        var oOpenInNew = {
            
            
            
            
            
            
             archives: ".archive-article-title", 
             miniArchives: "a.post-list-link", 
            
             friends: "#js-friends a", 
             socail: ".social a" 
        }
        for (var x in oOpenInNew) {
            $(oOpenInNew[x]).attr("target", "_blank");
        }
    
</script>

    <script>
        var originTitle = document.title;
        var titleTime;
        document.addEventListener("visibilitychange", function() {
            if (document.hidden) {
                document.title = "(つェ⊂) 我藏好了哦~ " + originTitle;
                clearTimeout(titleTime);
            }
            else {
                document.title = "(*´∇｀*) 被你发现啦~ " + originTitle;
                titleTime = setTimeout(function() {
                    document.title = originTitle;
                }, 2000);
            }
        })
    </script>

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
  </div>
</body>
</html>